import Opt from '@/components/dt/info/Opt.js'

// yearendApproval

class ApprovalColumn extends Opt {

  constructor(tabName) {
    super()
    this.tabName = tabName
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.auditName = {
      field: 'auditName',
      title: '审核人',
      visible: this.tabName == '1' || this.tabName == '2',
      minWidth: 130,
    }
    this.auditTime = {
      field: 'auditTime',
      title: '审核日期',
      visible: this.tabName == '1' || this.tabName == '2',
      minWidth: 120,
      cell: {
        text: {
          type: 'date'
        }
      }
    }
    this.auditReason = {
      field: 'auditReason',
      title: '驳回原因',
      visible: this.tabName == '2',
      minWidth: 150,
    }
    
    this.all = [{
        type: 'index',
        title: '序号',
        minWidth: 50,
      },
      {
        field: 'orgName',
        title: '所属组织',
        minWidth: 130
      },
      {
        field: 'auditData.bonusName',
        title: '奖金单名称',
        minWidth: 130
      },
      {
        field: 'auditData.bonusYear',
        title: '奖金单年份',
        minWidth: 100,
      },
      {
        field: 'auditData.bonusMonth',
        title: '涉及月份',
        minWidth: 110,
        cell: {
          value: (item) => `${item.auditData.bonusMonth}月`,
          text: {}
        }
      },
      {
        field: 'auditData.bonusAmount',
        title: '奖金总额(元)',
        minWidth: 150,
        cell: {
          text: {
            type: 'number'
          }
        }
      },
      {
        field: 'submitName',
        title: '提交人',
        minWidth: 130,
      },
      {
        field: 'submitTime',
        title: '提交日期',
        minWidth: 120,
        cell: {
          text: {
            type: 'date'
          }
        }
      },
      this.auditName,
      this.auditTime,
      this.auditReason,
      {
        title: '操作',
        width: 140,
        fixed: 'right',
        cell: (item) => {
          return {
            btn: [{
              title: '查看',
              event: 'onDetail'
            }, {
              title: '审批',
              code: '0206050601',
              visible: this.tabName == '0',
              event: 'onAudit'
            }]
          }
        }
      }
    ]
  }

}

export default ApprovalColumn
